<?php

namespace pmvc\mvc\view;

use pmvc\mvc\ViewHandler;
use pmvc\mvc\Request;
use pmvc\mvc\Response;

class JSONViewHandler 
    implements ViewHandler {
    	
    function renderView(Request $request, Response $response, $viewName) {
    	$response->setHeader("Content-Type", "application/json");
    	$json = json_encode($response->getModel());
    	$response->setHeader("Content-Length", strlen($json));
    	$response->getStream()->write($json);
    	$response->getStream()->flush();
    }
    
}

?>